package br.ita.supertrunfo.server.domain.transaction;

import java.util.Date;
import org.prevayler.TransactionWithQuery;

import br.ita.supertrunfo.server.domain.BaralhoIP;
import br.ita.supertrunfo.server.domain.CartaIP;


public class CartaCreateTransaction implements TransactionWithQuery {

    private int populacao;
    private int area;
    private int pib;
    private int idh;
    private int emissaoCo2;
    private String nome;
    private String continente;
    private String codigo;

    public CartaCreateTransaction(int populacao, int area, int pib, int idh, int co2, String nome, String continente, String codigo) {
		this.populacao = populacao;
		this.area = area;
		this.pib = pib;
		this.idh = idh;
		this.emissaoCo2 = co2;
		this.nome = nome;
		this.continente = continente;
		this.codigo = codigo;
    }

    public CartaCreateTransaction() {}

    public Object executeAndQuery(Object prevalentSystem, Date executionTime) throws Exception {
    	 
    	CartaIP newCarta = ((BaralhoIP) prevalentSystem).addCarta();  	
    	 newCarta.setArea(area);
    	 newCarta.setEmissaoCo2(emissaoCo2);
    	 newCarta.setIdh(idh);
    	 newCarta.setPib(pib);
    	 newCarta.setPopulacao(populacao);
    	 //newCarta.setNome(nome);
    	 //newCarta.setContinente(continente);
    	 newCarta.setCodigo(codigo);
    	 return newCarta;
	}

}